import request from "@/utils/request";
import { useStore } from "vuex";
// 创建团队
export const createdTeam = async (data = {}) => {
    return await request.post("/sxnf_team/team", data).then((res) => {
        return res;
    });
};

// 查询团队列表
export const teamList = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/get_my_team", data).then((res) => {
        return res;
    });
};

// 查询团队详情
export const teamMsg = async (id: number | string) => {
    return await request.get(`/sxnf_team/team/${id}`).then((res) => {
        return res;
    });
};
// 修改团队
export const updateTeamMsg = async (data = {}) => {
    return await request.put("/sxnf_team/team", data).then((res) => {
        return res;
    });
};
// // 获取团队列表
// export const companyList = async (data = {}) => {
//     return await request.get("/api/user/company/list", data).then((res) => {
//         // const store = useStore()
//         return res;
//     });
// };
// 查询机构类型
export const institutionalType = async (id: number | string) => {
    return await request.get(`/sxnf_team/classificationForOrganizations/getByParent/${id}`).then((res) => {
        return res;
    });
};
// 查询单个机构类型
export const institutionalTypeOne = async (id: number | string) => {
    return await request.get(`/sxnf_team/classificationForOrganizations/${id}`).then((res) => {
        return res;
    });
};
// 查询产业分类
export const industrialClassifications = async (id: number | string) => {
    return await request.get(`/sxnf_team/industrialClassification/getByParent/${id}`).then((res) => {
        return res;
    });
};

// 查询单个产业分类
export const industrialClassificationsOne = async (id: number | string) => {
    return await request.get(`/sxnf_team/industrialClassification/${id}`).then((res) => {
        return res;
    });
};

// 获取部门列表
export const departmentList = async (id: number | string, keyWords: string) => {
    return await request.get(`/sxnf_team/department/list?teamId=${id}&keyWords=${keyWords}`).then((res) => {
        return res;
    });
};

// 新建部门
export const creationDepartment = async (data = {}) => {
    return await request.post("/sxnf_team/department/add", data).then((res) => {
        return res;
    });
};
// 删除部门
export const deleteDepartment = async (data = {}) => {
    return await request.post("/sxnf_team/department/deleteById", data).then((res) => {
        return res;
    });
};
// 部门上移
export const departmentMoveUp = async (data = {}) => {
    return await request.post("/sxnf_team/department/moveUp", data).then((res) => {
        return res;
    });
};
// 部门下移
export const departmentMoveDown = async (data = {}) => {
    return await request.post("/sxnf_team/department/moveDown", data).then((res) => {
        return res;
    });
};
// 取消管理员
export const departmentCancelManager = async (data = {}) => {
    return await request.post("/sxnf_team/department/cancelManager", data).then((res) => {
        return res;
    });
};
// 修改部门
export const updateDepartment = async (data = {}) => {
    return await request.post("/sxnf_team/department/edit", data).then((res) => {
        return res;
    });
};
// 新增岗位
export const addPosition = async (data = {}) => {
    return await request.post("/sxnf_team/position", data).then((res) => {
        return res;
    });
};
// 修改岗位
export const updatePosition = async (data = {}) => {
    return await request.post("/sxnf_team/position/edit", data).then((res) => {
        return res;
    });
};
// 删除岗位
export const deletePosition = async (data = {}) => {
    return await request.post("/sxnf_team/position/deleteById", data).then((res) => {
        return res;
    });
};

// 获取岗位列表
export const getPosition = async (data = {}) => {
    return await request.get("/sxnf_team/position/list", data).then((res) => {
        return res;
    });
};

// 获取团队成员列表
export const getTeamMenber = async (id: number | string, data = {}) => {
    return await request.get(`/sxnf_team/userTeamPosition/page?teamId=${id}`, data).then((res) => {
        return res;
    });
};

// 设置部门主管
export const setDepartmentManager = async (data = {}) => {
    return await request.post("/sxnf_team/department/setManager", data).then((res) => {
        return res;
    });
};

// 移出部门成员
export const setDepartmentRemove = async (data = {}) => {
    return await request.post("/sxnf_team/department/setRemove", data).then((res) => {
        return res;
    });
};

// 设置主团队
export const setMainTeams = async (id: number | string) => {
    return await request.put(`/sxnf_team/userTeamPosition/set_main_team?teamId=${id}`).then((res) => {
        return res;
    });
};
// 申请团队认证
export const applyCertification = async (data = {}) => {
    return await request.post("/sxnf_team/team_certified/add", data).then((res) => {
        return res;
    });
};
// 获取团队认证信息
export const getApplyCertification = async (id: number | string) => {
    return await request.get(`/sxnf_team/team_certified/get_detail?teamId=${id}`).then((res) => {
        return res;
    });
};
// 修改团队认证
export const updateApplyCertification = async (data = {}) => {
    return await request.post("/sxnf_team/team_certified/edit", data).then((res) => {
        return res;
    });
};
// 获取所有团队列表
export const getAllTeamList = async (data = {}) => {
    return await request.get("/sxnf_team/team/page", data).then((res) => {
        return res;
    });
};
// // 根据id获取团队详情
// export const getTeamMsg = async (id: Number | string) => {
//     return await request.get(`/sxnf_team/team/${id}`).then((res) => {
//         return res;
//     });
// };
// 申请加入团队
export const applyToJoin = async (id: number | string) => {
    return await request.get(`/sxnf_team/userTeamPosition/join_team?teamId=${id}`).then((res) => {
        return res;
    });
};
// 退出团队
export const outToJoin = async (id: number | string) => {
    return await request.get(`/sxnf_team/userTeamPosition/retired_team?teamId=${id}`).then((res) => {
        return res;
    });
};
// 查询审核申请列表
export const getAuditApplyList = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/get_invitation", data).then((res) => {
        return res;
    });
};
// 查询审核结果列表
export const getApprovedMemoList = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/get_invitation_result", data).then((res) => {
        return res;
    });
};
// 团队审核
export const teamPosition = async (data = {}) => {
    return await request.post("/sxnf_team/team_certified/examineByCertifiedId", data).then((res) => {
        return res;
    });
};

// 审核通过
export const auditSucceed = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/agree", data).then((res) => {
        return res;
    });
};
// 审核不通过
export const auditErrors = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/disagree", data).then((res) => {
        return res;
    });
};
// 查询团队未加入任何部门的成员
export const getTeamNoDepartmentMenber = async (data = {}) => {
    return await request.get("/sxnf_user/user/search_not_join_by_team", data).then((res) => {
        return res;
    });
};
// 查询团队邀请的成员列表
export const getTeamNoInviteMenber = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/invitation_record", data).then((res) => {
        return res;
    });
};
// 邀请成员
export const invitationMenbers = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/invite", data).then((res) => {
        return res;
    });
};
// 查询部门下所有员工
export const getDepartmentMenbers = async (data = {}) => {
    return await request.get("/sxnf_team/department/query_user_by_department", data).then((res) => {
        return res;
    });
};
// 添加员工到部门
export const setMenberToDepartment = async (data = {}) => {
    return await request.post("/sxnf_team/department/set_position", data).then((res) => {
        return res;
    });
};
// 获取客户列表
export const getCustomer = async (data = {}) => {
    return await request.get("/sxnf_team/my_customer/queryByPage", data).then((res) => {
        return res;
    });
};
// 新增客户
export const setClient = async (data = {}) => {
    return await request.post("/sxnf_team/my_customer/add", data).then((res) => {
        return res;
    });
};
// 获取客户信息
export const getClientMsg = async (id: number | string) => {
    return await request.get(`/sxnf_team/my_customer/queryById/${id}`).then((res) => {
        return res;
    });
};
// 修改客户
export const putClient = async (data = {}) => {
    return await request.post("/sxnf_team/my_customer/edit", data).then((res) => {
        return res;
    });
};
// 删除客户
export const deleteClient = async (data = {}) => {
    return await request.post("/sxnf_team/my_customer/deleteById", data).then((res) => {
        return res;
    });
};
// 获取供应商列表
export const getSupplier = async (data = {}) => {
    return await request.get("/sxnf_team/my_supplier/queryByPage", data).then((res) => {
        return res;
    });
};
// 删除供应商
export const deleteSupplier = async (data = {}) => {
    return await request.post(`/sxnf_team/my_supplier/deleteById`, data).then((res) => {
        return res;
    });
};
// 新增供应商
export const setSupplier = async (data = {}) => {
    return await request.post("/sxnf_team/my_supplier/add", data).then((res) => {
        return res;
    });
};
// 获取供应商信息
export const getSupplierMsg = async (id: number | string) => {
    return await request.get(`/sxnf_team/my_supplier/queryById/${id}`).then((res) => {
        return res;
    });
};
// 修改供应商
export const putSupplier = async (data = {}) => {
    return await request.post("/sxnf_team/my_supplier/edit", data).then((res) => {
        return res;
    });
};

// 团队成员信息
export const teamMenuberMsg = async (data = {}) => {
    return await request.get("/sxnf_team/userTeamPosition/get_user_info", data).then((res) => {
        return res;
    });
};
// 删除团队成员
export const removeTeamMenber = async (data = {}) => {
    return await request.post("/sxnf_team/userTeamPosition/editByIdAndTeamId", data).then((res) => {
        return res;
    });
};
// 操作记录列表
export const operatingRecord = async (data = {}) => {
    return await request.get("/sxnf_team/teamLogRecord/page", data).then((res) => {
        return res;
    });
};
// 搜索客户供应商
export const getElseTeam = async (data = {}) => {
    return await request.get("/sxnf_team/team/getByTeamNameLike", data).then((res) => {
        return res;
    });
};
